package handler

import (
	"jx3_bot/common"

	"github.com/tidwall/gjson"
)

func ServerStatusHandle(uid, groupID, server string) {
	if server == "" {
		server = "梦江南" // 绑定默认服务器
	}
	url := "https://www.jx3api.com/data/server/check?server=" + server
	body, err := common.HttpGet(url)
	if err != nil {
		return
	}

	zone := gjson.Get(body, "data.zone").String()
	service := gjson.Get(body, "data.server").String()
	status := gjson.Get(body, "data.status").String()

	resp := "[Text]大区: " + zone +
		"[Line]服务器: " + service +
		"[Line]状态: " + status

	common.SendGroupMessage(groupID, resp, false)
}
